<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>百度换肤</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            /* 页面铺满设置 */
            width: 100%;
            height: 100%;
            background: url(images/spring.jpg) no-repeat center top;
            background-size: 100% 100%;
            background-attachment: fixed;
        }
        li{
            list-style: none;
        }
        .baidu{
            overflow: hidden;
            margin: 100px auto;
            background-color: #fff;
            width: 410px;
            padding-top: 3px;
        }
        .baidu li{
            float: left;
            margin: 0 1px;
            cursor: pointer;
        }
        .baidu img{
            width: 100px;
        }
    </style>
</head>
<body>
    <!-- 百度换肤效果 -->
    <ul class="baidu">
        <li><img src="1.jpg"></li>
        <li><img src="2.jpg"></li>
        <li><img src="3.jpg"></li>
        <li><img src="4.jpg"></li>
    </ul>
    <script>
        // 1. 获取元素
        var imgs=document.querySelector('.baidu').querySelectorAll('img');
        // 2. 循环注册事件
        for(var i=0;i<imgs.length;i++){
            imgs[i].onclick=function(){
                document.body.style.backgroundImage='url('+this.src+')';
            }
        }
    </script>
</body>
</html>